package com.ruoyi.project.task.postpone.service;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.task.mission.mapper.TaskMissionMapper;
import com.ruoyi.project.task.postpone.domain.TaskPostpone;
import com.ruoyi.project.task.postpone.mapper.TaskPostponeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Pathosis
 * @date 2020-09-18 15:23
 * @description: 延期任务的service实现类
 */
@Service
public class TaskPostponeServiceImpl implements ITaskPostponeService {

    @Autowired
    private TaskPostponeMapper tpm;

    @Autowired
    private TaskMissionMapper tmm;

    @Override
    public List<TaskPostpone> selectAllTaskPostpone(TaskPostpone taskPostpone) {
        return tpm.selectAllTaskPostpone(taskPostpone);
    }

    @Override
    public int insertTaskPostpone(TaskPostpone taskPostpone) {
        taskPostpone.setCreateBy(ShiroUtils.getLoginName());
        taskPostpone.setGiveState(UserConstants.TRANSFER_RATIFY_CODE);
        return tpm.insertTaskPostpone(taskPostpone);
    }

    @Override
    public int deleteTaskPostponeByIds(String ids) {
        Long[] postponeId = Convert.toLongArray(ids);
        return tpm.deleteTaskPostponeByIds(postponeId);
    }

    @Override
    public TaskPostpone selectTaskPostponeById(Long postponeId) {
        return tpm.selectTaskPostponeById(postponeId);
    }

    @Override
    public int updateTaskPostpone(TaskPostpone taskPostpone) {
        taskPostpone.setUpdateBy(ShiroUtils.getLoginName());
        return tpm.updateTaskPostpone(taskPostpone);
    }
}
